#coding=utf-8

from django.http import HttpResponse
from django.http import HttpResponsePermanentRedirect
from django.shortcuts import render_to_response
from syndication.feeds import Feed

from blog.models import Diary

def index(request):
	return render_to_response('index.html')

def login(request):
	if request.method == 'POST':
		pass
	return render_to_response('index.html')
		
def robots(request):
	return render_to_response('robots.txt')

def photo(request):
	return HttpResponsePermanentRedirect('http://picasaweb.google.com/zhlwish/')

class BlogFeed(Feed):
    title = '没有比人更高的山——周亮的博客'
    link = 'http://www.zhlwish.com/blog/'
    description = '周亮的博客，网址:http://www.zhlwish.com，EMail:zhlwish@gmail.com'
    cpoyright = 'Copyright (c) 2008, www.zhlwish.com'


    def items(self):
        return Diary.all().order('-post_time')[:10]

    def get_absolute_url(self, item):
        return 'http://www.zhlwish.com/blog/diary/%s/' % item.key()
    
    def item_title(self, item):
    	return item.title
    
    def item_content(self, item):
    	return item.content
    
    def item_link(self, item):
        return 'http://www.zhlwish.com/blog/diary/%s/' % item.key()
    
    def item_author_name(self, item):
        return  item.author
    
    def item_pubdate(self, item):
        return item.post_time
    
    def item_categories(self, item):
        return (item.category.name ,)

class DownloadFeed(Feed):
	pass

feeds_dic = {
         'blog':BlogFeed,
         'download': DownloadFeed,
}
